// Copyright 2019-2020 The MathWorks, Inc.
// Common copy functions for serial_pack/compareAtt
#include "boost/date_time.hpp"
#include "boost/shared_array.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4244)
#pragma warning(disable : 4265)
#pragma warning(disable : 4458)
#pragma warning(disable : 4100)
#pragma warning(disable : 4127)
#pragma warning(disable : 4267)
#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wredundant-decls"
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wshadow"
#endif //_MSC_VER
#include "ros/ros.h"
#include "serial_pack/compareAtt.h"
#include "visibility_control.h"
#include "class_loader/multi_library_class_loader.hpp"
#include "MATLABROSMsgInterface.hpp"
#include "ROSPubSubTemplates.hpp"
class SERIAL_PACK_EXPORT serial_pack_msg_compareAtt_common : public MATLABROSMsgInterface<serial_pack::compareAtt> {
  public:
    virtual ~serial_pack_msg_compareAtt_common(){}
    virtual void copy_from_struct(serial_pack::compareAtt* msg, const matlab::data::Struct& arr, MultiLibLoader loader); 
    //----------------------------------------------------------------------------
    virtual MDArray_T get_arr(MDFactory_T& factory, const serial_pack::compareAtt* msg, MultiLibLoader loader, size_t size = 1);
};
  void serial_pack_msg_compareAtt_common::copy_from_struct(serial_pack::compareAtt* msg, const matlab::data::Struct& arr,
               MultiLibLoader loader) {
    try {
        //pit1
        const matlab::data::TypedArray<float> pit1_arr = arr["Pit1"];
        msg->pit1 = pit1_arr[0];
    } catch (matlab::data::InvalidFieldNameException&) {
        throw std::invalid_argument("Field 'Pit1' is missing.");
    } catch (matlab::Exception&) {
        throw std::invalid_argument("Field 'Pit1' is wrong type; expected a single.");
    }
    try {
        //pit2
        const matlab::data::TypedArray<float> pit2_arr = arr["Pit2"];
        msg->pit2 = pit2_arr[0];
    } catch (matlab::data::InvalidFieldNameException&) {
        throw std::invalid_argument("Field 'Pit2' is missing.");
    } catch (matlab::Exception&) {
        throw std::invalid_argument("Field 'Pit2' is wrong type; expected a single.");
    }
    try {
        //rol1
        const matlab::data::TypedArray<float> rol1_arr = arr["Rol1"];
        msg->rol1 = rol1_arr[0];
    } catch (matlab::data::InvalidFieldNameException&) {
        throw std::invalid_argument("Field 'Rol1' is missing.");
    } catch (matlab::Exception&) {
        throw std::invalid_argument("Field 'Rol1' is wrong type; expected a single.");
    }
    try {
        //rol2
        const matlab::data::TypedArray<float> rol2_arr = arr["Rol2"];
        msg->rol2 = rol2_arr[0];
    } catch (matlab::data::InvalidFieldNameException&) {
        throw std::invalid_argument("Field 'Rol2' is missing.");
    } catch (matlab::Exception&) {
        throw std::invalid_argument("Field 'Rol2' is wrong type; expected a single.");
    }
    try {
        //yaw1
        const matlab::data::TypedArray<float> yaw1_arr = arr["Yaw1"];
        msg->yaw1 = yaw1_arr[0];
    } catch (matlab::data::InvalidFieldNameException&) {
        throw std::invalid_argument("Field 'Yaw1' is missing.");
    } catch (matlab::Exception&) {
        throw std::invalid_argument("Field 'Yaw1' is wrong type; expected a single.");
    }
    try {
        //yaw2
        const matlab::data::TypedArray<float> yaw2_arr = arr["Yaw2"];
        msg->yaw2 = yaw2_arr[0];
    } catch (matlab::data::InvalidFieldNameException&) {
        throw std::invalid_argument("Field 'Yaw2' is missing.");
    } catch (matlab::Exception&) {
        throw std::invalid_argument("Field 'Yaw2' is wrong type; expected a single.");
    }
  }
  //----------------------------------------------------------------------------
  MDArray_T serial_pack_msg_compareAtt_common::get_arr(MDFactory_T& factory, const serial_pack::compareAtt* msg,
       MultiLibLoader loader, size_t size) {
    auto outArray = factory.createStructArray({size,1},{"MessageType","Pit1","Pit2","Rol1","Rol2","Yaw1","Yaw2"});
    for(size_t ctr = 0; ctr < size; ctr++){
    outArray[ctr]["MessageType"] = factory.createCharArray("serial_pack/compareAtt");
    // pit1
    auto currentElement_pit1 = (msg + ctr)->pit1;
    outArray[ctr]["Pit1"] = factory.createScalar(currentElement_pit1);
    // pit2
    auto currentElement_pit2 = (msg + ctr)->pit2;
    outArray[ctr]["Pit2"] = factory.createScalar(currentElement_pit2);
    // rol1
    auto currentElement_rol1 = (msg + ctr)->rol1;
    outArray[ctr]["Rol1"] = factory.createScalar(currentElement_rol1);
    // rol2
    auto currentElement_rol2 = (msg + ctr)->rol2;
    outArray[ctr]["Rol2"] = factory.createScalar(currentElement_rol2);
    // yaw1
    auto currentElement_yaw1 = (msg + ctr)->yaw1;
    outArray[ctr]["Yaw1"] = factory.createScalar(currentElement_yaw1);
    // yaw2
    auto currentElement_yaw2 = (msg + ctr)->yaw2;
    outArray[ctr]["Yaw2"] = factory.createScalar(currentElement_yaw2);
    }
    return std::move(outArray);
  } 
class SERIAL_PACK_EXPORT serial_pack_compareAtt_message : public ROSMsgElementInterfaceFactory {
  public:
    virtual ~serial_pack_compareAtt_message(){}
    virtual std::shared_ptr<MATLABPublisherInterface> generatePublisherInterface(ElementType type);
    virtual std::shared_ptr<MATLABSubscriberInterface> generateSubscriberInterface(ElementType type);
};  
  std::shared_ptr<MATLABPublisherInterface> 
          serial_pack_compareAtt_message::generatePublisherInterface(ElementType type){
    if(type != eMessage){
        throw std::invalid_argument("Wrong input, Expected eMessage");
    }
    return std::make_shared<ROSPublisherImpl<serial_pack::compareAtt,serial_pack_msg_compareAtt_common>>();
  }
  std::shared_ptr<MATLABSubscriberInterface> 
         serial_pack_compareAtt_message::generateSubscriberInterface(ElementType type){
    if(type != eMessage){
        throw std::invalid_argument("Wrong input, Expected eMessage");
    }
    return std::make_shared<ROSSubscriberImpl<serial_pack::compareAtt,serial_pack::compareAtt::ConstPtr,serial_pack_msg_compareAtt_common>>();
  }
#include "class_loader/register_macro.hpp"
// Register the component with class_loader.
// This acts as a sort of entry point, allowing the component to be discoverable when its library
// is being loaded into a running process.
CLASS_LOADER_REGISTER_CLASS(serial_pack_msg_compareAtt_common, MATLABROSMsgInterface<serial_pack::compareAtt>)
CLASS_LOADER_REGISTER_CLASS(serial_pack_compareAtt_message, ROSMsgElementInterfaceFactory)
#ifdef _MSC_VER
#pragma warning(pop)
#else
#pragma GCC diagnostic pop
#endif //_MSC_VER
//gen-1